<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>按钮</button>
    <script>
         let obj = {
            myname:"zhangsan",
            age:20,
            height:"178cm"
        }
        function o2s(obj) {
            let keys = Object.keys(obj);
            let values = Object.values(obj);
            let res = keys.map((item,index) => {
                return `${item}=${values[index]}`;//循环拼接字符串，返回数组
            })
            return res.join('&');//将数组中的内容用&拼接，返回字符串
        }
        document.querySelector('button').onclick = function() {
            // ?name=zhangsan&age=20
            location.href = `./b.html?${o2s(obj)}`;
        }
        // o2s(obj);
    </script>
</body>
</html>